from google.appengine.ext import db

class PlayerInfo(db.Model):
    name = db.StringProperty(required=True)
    role = db.StringProperty()

class Player(db.Model):
    info = db.ReferenceProperty(PlayerInfo)
    isReady = db.BooleanProperty()
    latitude = db.FloatProperty()
    longitude = db.FloatProperty()

class Game(db.Model):
    name = db.StringProperty(required=True)
    password = db.StringProperty()
    playerKeys = db.ListProperty(db.Key)

    def players(self):
        players = []
        for playerKey in self.playerKeys:
            players.append(Player.get_by_id(playerKey.id()))

        return players